using UnityEngine;
using System.Collections;

public class WarningScreen : MonoBehaviour {
	
	public string sceneName;
	public float fadeAmount;
	public float stayTime;
	private float timer;
	private FadeIn fade;
	
	void Awake()
	{
		fade = (FadeIn) gameObject.AddComponent("FadeIn");
		gameObject.AddComponent("SceneChange");
		fade.createFade(fadeAmount);
			}
	
	void Update()
	{
		
		if(fade == null)
		{
			timer += Time.deltaTime;
		}
		
		if(timer > stayTime)
		{
			if(gameObject.GetComponent<SceneChange>().existFade())
			{
				if(PlayerPrefs.GetInt("ChangeSpeed",0) == 0)
				{
					gameObject.GetComponent<SceneChange>().createFade("SpeedAdjust", fadeAmount);
				}
				else
				{
					gameObject.GetComponent<SceneChange>().createFade(sceneName, fadeAmount);
				}
			}
		}

	}
}
